<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>BatteryCharger: charger.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">BatteryCharger
   &#160;<span id="projectnumber">5.0</span>
   </div>
   <div id="projectbrief">A smart charger for lead-acid batteries.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('charger_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#enum-members">Enumerations</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">charger.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><a href="charger_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">ADC measurement averaging parameters.</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>The voltage and current measurements are averaged over many samples because the measurements are not synchronized to the PWM signal, and they are fairly noisy. For convenience, the averaging is actually done with a moving-average filter. There is a separate filter for battery voltage that has a shorter time constant; this is used for fault detection purposes and we want to react quickly to gross changes in the battery voltage. </p>
</div></td></tr>
<tr class="memitem:af7c58a614424d78e44e2b6d844959346"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#af7c58a614424d78e44e2b6d844959346">SAMPLES_FAST_AVERAGE</a>&#160;&#160;&#160;64</td></tr>
<tr class="separator:af7c58a614424d78e44e2b6d844959346"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab78b5dd637d266b4c3f5642da81ba69e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#ab78b5dd637d266b4c3f5642da81ba69e">SAMPLES_TO_AVERAGE</a>&#160;&#160;&#160;512</td></tr>
<tr class="separator:ab78b5dd637d266b4c3f5642da81ba69e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Voltage sensing scale factors.</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>The scale factor from battery voltage to ADC input voltage is specified using two values, a numerator term (<a class="el" href="charger_8h.html#a236e185c458da8c4305d3bb63fa98df6">V_SCALE_NUMERATOR</a>) and a denominator term (<a class="el" href="charger_8h.html#a00636604332cb667db002f53b69bd1ec">V_SCALE_DENOMINATOR</a>). This is just for convenience, because these values are only used at compile-time to determine the battery voltage, in mV, that corresponds to a full scale ADC reading. It is this value, <a class="el" href="charger_8h.html#a50c835c628316f78a55515a58589e3c2">V_MAX_MV</a>, that is used to convert ADC values to actual voltages at run time. </p>
</div></td></tr>
<tr class="memitem:a236e185c458da8c4305d3bb63fa98df6"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a236e185c458da8c4305d3bb63fa98df6">V_SCALE_NUMERATOR</a>&#160;&#160;&#160;5000</td></tr>
<tr class="separator:a236e185c458da8c4305d3bb63fa98df6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a00636604332cb667db002f53b69bd1ec"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a00636604332cb667db002f53b69bd1ec">V_SCALE_DENOMINATOR</a>&#160;&#160;&#160;1000</td></tr>
<tr class="separator:a00636604332cb667db002f53b69bd1ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a50c835c628316f78a55515a58589e3c2"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a50c835c628316f78a55515a58589e3c2">V_MAX_MV</a>&#160;&#160;&#160;((<a class="el" href="adc_8h.html#a1c77a4467697f72f3d6ed3b5effd7182">ADC_VREF_MV</a>*<a class="el" href="charger_8h.html#a236e185c458da8c4305d3bb63fa98df6">V_SCALE_NUMERATOR</a>)/<a class="el" href="charger_8h.html#a00636604332cb667db002f53b69bd1ec">V_SCALE_DENOMINATOR</a>)</td></tr>
<tr class="separator:a50c835c628316f78a55515a58589e3c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Current sensing scale factors.</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>The scale factor from battery current (in amperes) to ADC input voltage (in volts) is specified using two values, a numerator term (<a class="el" href="charger_8h.html#af8388d9a82ee5d20fc2d73121ccdb865">I_SCALE_NUMERATOR</a>) and a denominator term (<a class="el" href="charger_8h.html#a6694bd50b6bb606f9bee605d7aa44fe1">I_SCALE_DENOMINATOR</a>). This is just for convenience, because these values are only used at compile-time to determine the charging current, in mA, that corresponds to a full scale ADC reading. It is this value, <a class="el" href="charger_8h.html#a4664d8f2c7b5fc7c1619a86f0ec4b22d">I_MAX_MA</a>, that is used to convert ADC values to actual voltages at run time. </p>
</div></td></tr>
<tr class="memitem:af8388d9a82ee5d20fc2d73121ccdb865"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#af8388d9a82ee5d20fc2d73121ccdb865">I_SCALE_NUMERATOR</a>&#160;&#160;&#160;1000</td></tr>
<tr class="separator:af8388d9a82ee5d20fc2d73121ccdb865"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6694bd50b6bb606f9bee605d7aa44fe1"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a6694bd50b6bb606f9bee605d7aa44fe1">I_SCALE_DENOMINATOR</a>&#160;&#160;&#160;1000</td></tr>
<tr class="separator:a6694bd50b6bb606f9bee605d7aa44fe1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4664d8f2c7b5fc7c1619a86f0ec4b22d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a4664d8f2c7b5fc7c1619a86f0ec4b22d">I_MAX_MA</a>&#160;&#160;&#160;((<a class="el" href="adc_8h.html#a1c77a4467697f72f3d6ed3b5effd7182">ADC_VREF_MV</a>*<a class="el" href="charger_8h.html#af8388d9a82ee5d20fc2d73121ccdb865">I_SCALE_NUMERATOR</a>)/<a class="el" href="charger_8h.html#a6694bd50b6bb606f9bee605d7aa44fe1">I_SCALE_DENOMINATOR</a>)</td></tr>
<tr class="separator:a4664d8f2c7b5fc7c1619a86f0ec4b22d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Fault detection voltage levels</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>The battery voltage is compared to two voltage levels in an attempt to detect whether the battery has been disconnected or the battery terminals have been shorted. These checks are only made while the charger is in a constant-current mode. If the battery voltage is below <a class="el" href="charger_8h.html#a155b9d569ca9278041cbc9692ef10107">SHORT_VOLTAGE_MV</a> or above <a class="el" href="charger_8h.html#a6dc1bd0a4ebfb54241782dc63ac3ec9b">OPEN_VOLTAGE_MV</a> we assume that there is some kind of fault and shut down the charger. </p>
</div></td></tr>
<tr class="memitem:a155b9d569ca9278041cbc9692ef10107"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a155b9d569ca9278041cbc9692ef10107">SHORT_VOLTAGE_MV</a>&#160;&#160;&#160;11000</td></tr>
<tr class="separator:a155b9d569ca9278041cbc9692ef10107"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6dc1bd0a4ebfb54241782dc63ac3ec9b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a6dc1bd0a4ebfb54241782dc63ac3ec9b">OPEN_VOLTAGE_MV</a>&#160;&#160;&#160;15000</td></tr>
<tr class="separator:a6dc1bd0a4ebfb54241782dc63ac3ec9b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Stage 1 voltage limit and current value</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>These parameters set the current level used for constant-current charging and the voltage level that must be reached (the battery voltage must rise to) in order to advance to the next charging stage. </p>
</div></td></tr>
<tr class="memitem:acc1654433c4c1af7ad32859fc0ebb318"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#acc1654433c4c1af7ad32859fc0ebb318">MODE1_VOLTAGE_MV</a>&#160;&#160;&#160;14400</td></tr>
<tr class="separator:acc1654433c4c1af7ad32859fc0ebb318"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a75719826231baaded30955287d81da29"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a75719826231baaded30955287d81da29">MODE1_CURRENT_MA</a>&#160;&#160;&#160;1800</td></tr>
<tr class="separator:a75719826231baaded30955287d81da29"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Stage 2 voltage value and current limit</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>These parameters set the voltage level used for constant-voltage charging and the current level that must be reached (the charging current must fall to) in order to advance to the next charging stage. </p>
</div></td></tr>
<tr class="memitem:a3dbda1866df5cd0bc16fab99924bdb5d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a3dbda1866df5cd0bc16fab99924bdb5d">MODE2_VOLTAGE_MV</a>&#160;&#160;&#160;14400</td></tr>
<tr class="separator:a3dbda1866df5cd0bc16fab99924bdb5d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9fac06211d62c1a2967d00a6e50c54c1"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a9fac06211d62c1a2967d00a6e50c54c1">MODE2_CURRENT_MA</a>&#160;&#160;&#160;100</td></tr>
<tr class="separator:a9fac06211d62c1a2967d00a6e50c54c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Stage 3 voltage value</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>This parameter sets the voltage for trickle charging in stage 3. </p>
</div></td></tr>
<tr class="memitem:a653480f2af346947a14055dbddb464f5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a653480f2af346947a14055dbddb464f5">MODE3_VOLTAGE_MV</a>&#160;&#160;&#160;12900</td></tr>
<tr class="separator:a653480f2af346947a14055dbddb464f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">START button connection</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>These parameters specify the name of the GPIO port, and the bit position within that port, where the <b>START</b> button is connected. We also define a function macro that returns a boolean true value if the button is being pressed. </p>
</div></td></tr>
<tr class="memitem:a1d5c9bdfffcd88931bcab5add8f69330"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a1d5c9bdfffcd88931bcab5add8f69330">BTN1_PORT</a>&#160;&#160;&#160;LPC_GPIO1</td></tr>
<tr class="separator:a1d5c9bdfffcd88931bcab5add8f69330"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d2171fc428bb1690de2d6d35f11fae9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a0d2171fc428bb1690de2d6d35f11fae9">BTN1_Pos</a>&#160;&#160;&#160;8</td></tr>
<tr class="separator:a0d2171fc428bb1690de2d6d35f11fae9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a88d687ec0270b05e20c85c83f191a024"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a88d687ec0270b05e20c85c83f191a024">BUTTON1_PRESSED</a>&#160;&#160;&#160;(~(<a class="el" href="charger_8h.html#a1d5c9bdfffcd88931bcab5add8f69330">BTN1_PORT</a>-&gt;DATA) &amp; (1uL &lt;&lt; BTN1_Pos))</td></tr>
<tr class="separator:a88d687ec0270b05e20c85c83f191a024"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr><td colspan="2"><div class="groupHeader">Diagnostic output</div></td></tr>
<tr><td colspan="2"><div class="groupText"><p>These parameters specify the name of a GPIO port, and the bit position within that port, for a diagnostic output pin. A mask value is defined that can be used to set or clear this output pin. </p>
</div></td></tr>
<tr class="memitem:afc6a495708d126d07577bdd74cd693e9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#afc6a495708d126d07577bdd74cd693e9">FLAG1_PORT</a>&#160;&#160;&#160;LPC_GPIO1</td></tr>
<tr class="separator:afc6a495708d126d07577bdd74cd693e9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acedebf22a3c3cacb217471d48d37a8f5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#acedebf22a3c3cacb217471d48d37a8f5">FLAG1_Pos</a>&#160;&#160;&#160;5</td></tr>
<tr class="separator:acedebf22a3c3cacb217471d48d37a8f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adb0d94571d7ef7df43a94647c13a730a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#adb0d94571d7ef7df43a94647c13a730a">FLAG1_Msk</a>&#160;&#160;&#160;(1 &lt;&lt; <a class="el" href="charger_8h.html#acedebf22a3c3cacb217471d48d37a8f5">FLAG1_Pos</a>)</td></tr>
<tr class="separator:adb0d94571d7ef7df43a94647c13a730a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:af912b18af8de205312a5d27282e95cde"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cde">ChargerState</a> { <br/>
&#160;&#160;<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea2fd6f336d08340583bd620a7f5694c90">ERROR</a> = 0, 
<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeaaab5a2bcea860b4f52557e01cb37c66f">CALIBRATE</a>, 
<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea84e04feeb70146c1d6f609660d20cea0">WAIT4BUTTON</a>, 
<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeac53ee90175038245e571a7afe7985feb">CHECK4BATT</a>, 
<br/>
&#160;&#160;<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdeacad1f95421284c28d462180d85c320e9">CC_CHARGE</a>, 
<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea51ed40b70a4a73164180010de321e4a9">CV_CHARGE</a>, 
<a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cdea50641d73493fcffb14b565b51a27d6f3">TRICKLE</a>
<br/>
 }</td></tr>
<tr class="separator:af912b18af8de205312a5d27282e95cde"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:ad81e98c190f340de41b9d2092d640cdd"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#ad81e98c190f340de41b9d2092d640cdd">State</a></td></tr>
<tr class="separator:ad81e98c190f340de41b9d2092d640cdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a072b3046a3b425f96c26c3bb1a9376b8"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a072b3046a3b425f96c26c3bb1a9376b8">FastVoltage</a></td></tr>
<tr class="separator:a072b3046a3b425f96c26c3bb1a9376b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0142489055e8b3b737784a72afddf73b"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a0142489055e8b3b737784a72afddf73b">RawCurrent</a></td></tr>
<tr class="separator:a0142489055e8b3b737784a72afddf73b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a83e89a22da06d138a4a9373955d02d34"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a83e89a22da06d138a4a9373955d02d34">RawVoltage</a></td></tr>
<tr class="separator:a83e89a22da06d138a4a9373955d02d34"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3edd7bb06bb02480aecd235e8ae70219"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="charger_8h.html#a3edd7bb06bb02480aecd235e8ae70219">Temperature</a></td></tr>
<tr class="separator:a3edd7bb06bb02480aecd235e8ae70219"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><dl class="section author"><dt>Author</dt><dd>K. Joseph Hass </dd></dl>
<dl class="section date"><dt>Date</dt><dd>Created: 2014-01-07T20:02:08-0500 </dd>
<dd>
Last modified: 2014-01-12T17:50:55-0500</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) 2014 Kenneth Joseph Hass</dd>
<dd>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</dd>
<dd>
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a1d5c9bdfffcd88931bcab5add8f69330"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BTN1_PORT&#160;&#160;&#160;LPC_GPIO1</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a0d2171fc428bb1690de2d6d35f11fae9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BTN1_Pos&#160;&#160;&#160;8</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a88d687ec0270b05e20c85c83f191a024"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BUTTON1_PRESSED&#160;&#160;&#160;(~(<a class="el" href="charger_8h.html#a1d5c9bdfffcd88931bcab5add8f69330">BTN1_PORT</a>-&gt;DATA) &amp; (1uL &lt;&lt; BTN1_Pos))</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="adb0d94571d7ef7df43a94647c13a730a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define FLAG1_Msk&#160;&#160;&#160;(1 &lt;&lt; <a class="el" href="charger_8h.html#acedebf22a3c3cacb217471d48d37a8f5">FLAG1_Pos</a>)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="afc6a495708d126d07577bdd74cd693e9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define FLAG1_PORT&#160;&#160;&#160;LPC_GPIO1</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="acedebf22a3c3cacb217471d48d37a8f5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define FLAG1_Pos&#160;&#160;&#160;5</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a4664d8f2c7b5fc7c1619a86f0ec4b22d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define I_MAX_MA&#160;&#160;&#160;((<a class="el" href="adc_8h.html#a1c77a4467697f72f3d6ed3b5effd7182">ADC_VREF_MV</a>*<a class="el" href="charger_8h.html#af8388d9a82ee5d20fc2d73121ccdb865">I_SCALE_NUMERATOR</a>)/<a class="el" href="charger_8h.html#a6694bd50b6bb606f9bee605d7aa44fe1">I_SCALE_DENOMINATOR</a>)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a6694bd50b6bb606f9bee605d7aa44fe1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define I_SCALE_DENOMINATOR&#160;&#160;&#160;1000</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="af8388d9a82ee5d20fc2d73121ccdb865"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define I_SCALE_NUMERATOR&#160;&#160;&#160;1000</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a75719826231baaded30955287d81da29"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MODE1_CURRENT_MA&#160;&#160;&#160;1800</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="acc1654433c4c1af7ad32859fc0ebb318"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MODE1_VOLTAGE_MV&#160;&#160;&#160;14400</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a9fac06211d62c1a2967d00a6e50c54c1"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MODE2_CURRENT_MA&#160;&#160;&#160;100</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a3dbda1866df5cd0bc16fab99924bdb5d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MODE2_VOLTAGE_MV&#160;&#160;&#160;14400</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a653480f2af346947a14055dbddb464f5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MODE3_VOLTAGE_MV&#160;&#160;&#160;12900</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a6dc1bd0a4ebfb54241782dc63ac3ec9b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define OPEN_VOLTAGE_MV&#160;&#160;&#160;15000</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="af7c58a614424d78e44e2b6d844959346"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SAMPLES_FAST_AVERAGE&#160;&#160;&#160;64</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="ab78b5dd637d266b4c3f5642da81ba69e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SAMPLES_TO_AVERAGE&#160;&#160;&#160;512</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a155b9d569ca9278041cbc9692ef10107"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SHORT_VOLTAGE_MV&#160;&#160;&#160;11000</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a50c835c628316f78a55515a58589e3c2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define V_MAX_MV&#160;&#160;&#160;((<a class="el" href="adc_8h.html#a1c77a4467697f72f3d6ed3b5effd7182">ADC_VREF_MV</a>*<a class="el" href="charger_8h.html#a236e185c458da8c4305d3bb63fa98df6">V_SCALE_NUMERATOR</a>)/<a class="el" href="charger_8h.html#a00636604332cb667db002f53b69bd1ec">V_SCALE_DENOMINATOR</a>)</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a00636604332cb667db002f53b69bd1ec"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define V_SCALE_DENOMINATOR&#160;&#160;&#160;1000</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a236e185c458da8c4305d3bb63fa98df6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define V_SCALE_NUMERATOR&#160;&#160;&#160;5000</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a class="anchor" id="af912b18af8de205312a5d27282e95cde"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="charger_8h.html#af912b18af8de205312a5d27282e95cde">ChargerState</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdea2fd6f336d08340583bd620a7f5694c90"></a>ERROR</em>&#160;</td><td class="fielddoc">
<p>The ERROR state will be entered when a fault condition is detected. The PWM output is disabled. This is a terminal state, and the STOP button must be pressed to reset the charger after an error. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdeaaab5a2bcea860b4f52557e01cb37c66f"></a>CALIBRATE</em>&#160;</td><td class="fielddoc">
<p>If the START button is held down at power-up or when the STOP button is pressed, the charger will enter the CALIBRATE state. This is a terminal state. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdea84e04feeb70146c1d6f609660d20cea0"></a>WAIT4BUTTON</em>&#160;</td><td class="fielddoc">
<p>If the START button NOT is held down at power-up or when the STOP button is pressed, the charger will enter the WAIT4BUTTON state. We start measuring the battery voltage but the PWM is not yet enabled. When the START button is then pressed the charger goes to the CHECK4BATT state. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdeac53ee90175038245e571a7afe7985feb"></a>CHECK4BATT</em>&#160;</td><td class="fielddoc">
<p>The charger is in the CHECK4BATT state for just one SysTick. The PWM output is still disabled and the charger just checks the voltage at the battery terminals. If the voltage is too low or too high then the charger goes to the ERROR state. If the voltage is within limits the charger goes to the CC_CHARGE state. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdeacad1f95421284c28d462180d85c320e9"></a>CC_CHARGE</em>&#160;</td><td class="fielddoc">
<p>The charger state is CC_CHARGE in the first stage of charging. We stay in this state until the voltage rises to the level specified by <a class="el" href="charger_8h.html#acc1654433c4c1af7ad32859fc0ebb318">MODE1_VOLTAGE_MV</a> and then goes to the CV_CHARGE state. The charger also checks for a disconnected or shorted battery during this stage. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdea51ed40b70a4a73164180010de321e4a9"></a>CV_CHARGE</em>&#160;</td><td class="fielddoc">
<p>The second stage of charging is the CV_CHARGE state. The charger stays in this state until the charging current falls below <a class="el" href="charger_8h.html#a9fac06211d62c1a2967d00a6e50c54c1">MODE2_CURRENT_MA</a>, then it enters the TRICKLE state. </p>
</td></tr>
<tr><td class="fieldname"><em><a class="anchor" id="af912b18af8de205312a5d27282e95cdea50641d73493fcffb14b565b51a27d6f3"></a>TRICKLE</em>&#160;</td><td class="fielddoc">
<p>The TRICKLE state is a constant-voltage charging mode with a lower voltage than that used in the CV_CHARGE state. This is a terminal state, and the charger and battery can safely remain in this state indefinitely. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a class="anchor" id="a072b3046a3b425f96c26c3bb1a9376b8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t FastVoltage</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a0142489055e8b3b737784a72afddf73b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t RawCurrent</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a83e89a22da06d138a4a9373955d02d34"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t RawVoltage</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="ad81e98c190f340de41b9d2092d640cdd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t State</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a3edd7bb06bb02480aecd235e8ae70219"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t Temperature</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_bfccd401955b95cf8c75461437045ac0.html">inc</a></li><li class="navelem"><a class="el" href="charger_8h.html">charger.h</a></li>
    <li class="footer">Generated on Mon Jan 13 2014 08:36:57 for BatteryCharger by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
